# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

BASE_VER ?= 125070

DBUSXX_XML2CPP ?= dbusxx-xml2cpp
PKG_CONFIG ?= pkg-config
PC_DEPS = dbus-1 dbus-c++-1 libchrome-$(BASE_VER) libchromeos-$(BASE_VER)
PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
CXXFLAGS += $(PC_CFLAGS)
BINDINGS := adaptors/org.chromium.tpmd.h adaptors/org.chromium.tpmd.nvram.h

include common.mk

CXXFLAGS += -fvisibility=hidden
CXXFLAGS += -I$(OUT)

all: CXX_BINARY(tpmd)

OBJS := main.o tpmd.o volatile_nvram.o

CXX_BINARY(tpmd): main.o $(OBJS)
	$(call cxx_binary,$(PC_LIBS))
clean: CXX_BINARY(tpmd)

adaptors/%.h: ../share/%.xml
	mkdir -p $(dir $@)
	$(DBUSXX_XML2CPP) $^ --adaptor=$@ --adaptor-template=ef-adaptor-stubs.tpl

main.o.depends: $(BINDINGS)
tpmd.o.depends: $(BINDINGS)
volatile_nvram.o.depends: $(BINDINGS)

install: all
	install -D -m 755 $(OUT)tpmd $(DESTDIR)/usr/sbin/tpmd
